package card;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class CardDemo {
    //第一步：先生成52张牌
    //第二步，洗牌，打乱牌的顺序
    //第三步：让三个人开牌，每个人开五张

//生成52张牌
    public static ArrayList<Card> generate() {
        String[] colors = new String[]{"♥","♠","♣","♦"};
        int[] nums = new int[]{1,2,3,4,5,6,7,8,9,10,11,12,13};

        ArrayList<Card> cards = new ArrayList<>(52);


        for (int i = 0; i < colors.length; i++) {
            for (int j = 0; j < nums.length; j++) {
                cards.add(new Card(colors[i], nums[j]));

            }
        }

        return cards;
    }


    //洗牌
    public static void shuffle(ArrayList<Card> cards) {
        Random random = new Random();

        for (int i = 0; i < cards.size(); i++) {
            int randomNumber = random.nextInt(52);
            cards.set(randomNumber,cards.get(i));
        }

    }

    //让三个人分别开五张牌
    public static Person[] play(ArrayList<Card> cards) {
        Person[] persons = new Person[3];
        for (int i = 0; i < persons.length; i++) {
            persons[i] = new Person();
        }
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < persons.length; j++) {
                persons[j].getHandCards().add(cards.remove(0));
            }
        }

        return persons;
    }




}
